//
//  UnionpayCell.m
//  JiFengDaRen
//
//  Created by Lyc on 2017/11/3.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//

#import "UnionpayCell.h"

@interface UnionpayCell ()

@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)UIImageView *unionpayImgView;
@property(nonatomic,strong)UIImageView *arrowImgView;

@end

@implementation UnionpayCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    
    _bgView = [[UIView alloc]init];
    _bgView.layer.cornerRadius = 5;
    _bgView.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:.15] CGColor];
    [self addSubview:_bgView];
    
    _unionpayImgView = [[UIImageView alloc]init];
    _unionpayImgView.contentMode = UIViewContentModeScaleAspectFit;
    [_bgView addSubview:_unionpayImgView];
    
    _payNewImgView = [[UIImageView alloc]init];
    [_bgView addSubview:_payNewImgView];
    
    _lable = [[UILabel alloc]init];
    _lable.font = KSystemFont(__I6Width(15));
    _lable.textColor = [UIColor colorWithHexString:@"#ffffff"];
    _lable.text = @"";
    [_bgView addSubview:_lable];
    
    _arrowImgView = [[UIImageView alloc]init];
    _arrowImgView.image = [UIImage imageNamed:@"arrowImg"];
    [_bgView addSubview:_arrowImgView];
}

- (void)layoutSubviews{
    
    
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top);
        make.centerX.mas_equalTo(self.mas_centerX);
        make.width.mas_equalTo(KScreenWidth - __I6Width(50));
        make.height.mas_equalTo(__I6Height(55));
    }];
    
    [_unionpayImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY);
        make.left.mas_equalTo(_bgView.mas_left).mas_offset(__I6Width(15));
        make.width.mas_equalTo(__I6Width(30));
        make.height.mas_equalTo(__I6Height(30));
    }];
    
    [_payNewImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(_bgView.mas_left).mas_offset(__I6Width(30));
        make.top.mas_equalTo(_bgView.mas_top).mas_offset(__I6Width(10));
        make.width.mas_equalTo(__I6Width(25));
        make.height.mas_equalTo(__I6Width(9));
    }];
    
    
    
    [_lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY);
        make.left.mas_equalTo(_unionpayImgView.mas_right).mas_offset(__I6Width(10));
        make.height.mas_equalTo(__I6Height(15));
    }];
    
    [_arrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_bgView.mas_centerY);
        make.right.mas_equalTo(_bgView.mas_right).mas_offset(__I6Width(-21));
        make.width.mas_equalTo(__I6Height(8));
        make.height.mas_equalTo(__I6Height(14));
    }];
}


- (void)setLeftImg:(NSString *)imaName paymentName:(NSString *)paymentName{
    
    _unionpayImgView.image  = [UIImage imageNamed:imaName];
    _lable.text = paymentName;
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    
    [super setHighlighted:highlighted animated:YES];
    if (highlighted) {
        
        _bgView.layer.backgroundColor = [UIColor colorWithWhite:242/255.0 alpha:0.3].CGColor;

    }else{
        _bgView.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:.15] CGColor];

    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
    
    [super setSelected:selected animated:animated];
    if (selected) {
        
        _bgView.layer.backgroundColor = [UIColor colorWithWhite:242/255.0 alpha:1].CGColor;
        
    }else{
        
        _bgView.layer.backgroundColor = [[UIColor colorWithRed:255.0f/255.0f green:255.0f/255.0f blue:255.0f/255.0f alpha:.15] CGColor];
        
    }
}

@end
